package com.yzxb.messystem.entity;

import java.time.LocalDateTime;

/**
 * 工单实体类
 */
public class WorkOrder {
    private Long id;
    
    private String orderCode;
    
    // 产品ID，用于关联产品
    private Long productId;
    
    // 产品对象，用于业务层关联查询
    private Product product;
    
    private Integer plannedQuantity;
    
    private Integer completedQuantity;
    
    private Integer rejectedQuantity;
    
    private OrderStatus status;
    
    private LocalDateTime plannedStartDate;
    
    private LocalDateTime plannedEndDate;
    
    private LocalDateTime actualStartDate;
    
    private LocalDateTime actualEndDate;
    
    private String productionLine;
    
    private String remarks;
    
    private LocalDateTime createTime;
    
    private LocalDateTime updateTime;
    
    // 工单状态枚举
    public enum OrderStatus {
        PENDING, // 待处理
        IN_PROGRESS, // 进行中
        COMPLETED, // 已完成
        CANCELLED, // 已取消
        ON_HOLD // 暂停
    }
    
    // 这些方法可以在服务层中处理，或者通过MyBatis-Plus的插件来实现
    public void setCreateTimeDefault() {
        createTime = LocalDateTime.now();
        updateTime = LocalDateTime.now();
        if (status == null) {
            status = OrderStatus.PENDING;
        }
        if (completedQuantity == null) {
            completedQuantity = 0;
        }
        if (rejectedQuantity == null) {
            rejectedQuantity = 0;
        }
    }
    
    public void setUpdateTimeDefault() {
        updateTime = LocalDateTime.now();
    }
    
    // Getters and Setters
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getOrderCode() {
        return orderCode;
    }
    
    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }
    
    public Long getProductId() {
        return productId;
    }
    
    public void setProductId(Long productId) {
        this.productId = productId;
    }
    
    public Product getProduct() {
        return product;
    }
    
    public void setProduct(Product product) {
        this.product = product;
    }
    
    public Integer getPlannedQuantity() {
        return plannedQuantity;
    }
    
    public void setPlannedQuantity(Integer plannedQuantity) {
        this.plannedQuantity = plannedQuantity;
    }
    
    public Integer getCompletedQuantity() {
        return completedQuantity;
    }
    
    public void setCompletedQuantity(Integer completedQuantity) {
        this.completedQuantity = completedQuantity;
    }
    
    public Integer getRejectedQuantity() {
        return rejectedQuantity;
    }
    
    public void setRejectedQuantity(Integer rejectedQuantity) {
        this.rejectedQuantity = rejectedQuantity;
    }
    
    public OrderStatus getStatus() {
        return status;
    }
    
    public void setStatus(OrderStatus status) {
        this.status = status;
    }
    
    public LocalDateTime getPlannedStartDate() {
        return plannedStartDate;
    }
    
    public void setPlannedStartDate(LocalDateTime plannedStartDate) {
        this.plannedStartDate = plannedStartDate;
    }
    
    public LocalDateTime getPlannedEndDate() {
        return plannedEndDate;
    }
    
    public void setPlannedEndDate(LocalDateTime plannedEndDate) {
        this.plannedEndDate = plannedEndDate;
    }
    
    public LocalDateTime getActualStartDate() {
        return actualStartDate;
    }
    
    public void setActualStartDate(LocalDateTime actualStartDate) {
        this.actualStartDate = actualStartDate;
    }
    
    public LocalDateTime getActualEndDate() {
        return actualEndDate;
    }
    
    public void setActualEndDate(LocalDateTime actualEndDate) {
        this.actualEndDate = actualEndDate;
    }
    
    public String getProductionLine() {
        return productionLine;
    }
    
    public void setProductionLine(String productionLine) {
        this.productionLine = productionLine;
    }
    
    public String getRemarks() {
        return remarks;
    }
    
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
    
    public LocalDateTime getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }
    
    public LocalDateTime getUpdateTime() {
        return updateTime;
    }
    
    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }
}